// JavaScript Document
(function(){
	$.fn.slide=function(options){
		var opt={currentimg:null,movetime:0,currentList:null,currentAList:null};
		$(this).each(function(){
			$(this).find("li").css("opacity","0").eq(0).css({"opacity":"1","zIndex":111});
			opt.currentimg=$(this).find("li").eq(0);
			opt.currentList=$(this).find("li");
			opt.currentAList=$(this).next(".miniImg").find("span");
			opt.currentAList.removeClass("active").eq(0).addClass("active");
			opt.movetime=setInterval(autoRun,4000);
			opt.currentAList.click(function(){
				if(opt.movetime)
					clearInterval(opt.movetime);
				$(this).addClass("active").siblings("active");
				opt.currentimg=opt.currentList.eq(opt.currentAList.index(this));
				showimg();
				opt.movetime=setInterval(autoRun,500);
			});
		});
		function autoRun(){
			if(opt.currentimg.hasClass("last")){
				opt.currentimg=opt.currentList.eq(0);
			}
			else{
				opt.currentimg=opt.currentimg.next();
			}
			showimg();
		};
		function showimg(){
			opt.currentimg.animate({"opacity":1},1000).css("zIndex",111).siblings().animate({"opacity":0},1000).css("zIndex",1);
			opt.currentAList.eq(opt.currentList.index(opt.currentimg)).addClass("active").siblings().removeClass("active");
	}
	}
})(jQuery)